<include file="Public/header" />
<include file="Public/menu" />

<!-- 内容页 -->
<div class="content-wrapper">
    <!-- 面包屑 -->
    <section class="content-header">
        <h1>
            首页
            <small>管理</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页管理</a></li>
            <li class="active">新增轮播图</li>
        </ol>
    </section>

    <!-- 内容 -->
    <section class="content"><div class="row"><div class="col-md-12">
        <div class="box box-info">
            <div class="box-header with-border">
                <h3 class="box-title">新增轮播图</h3>

                <div class="box-tools">

                    <div class="btn-group pull-right" style="margin-right: 10px">
                        <a href="/admin/carousel/index" class="btn btn-sm btn-default"><i class="fa fa-list"></i>&nbsp;轮播图列表</a>
                    </div>
                </div>
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <form action="/admin/carousel/add" id="form" method="post" accept-charset="UTF-8" class="form-horizontal" pjax-container="">
                <div class="box-body">
                    <div class="form-group 1">
                        <label class="col-sm-2 control-label">类型</label>
                        <div class="col-sm-6">
                            <select class="form-control  select2-hidden-accessible" style="width: 100%;" id="Continent" name="type" tabindex="-1" aria-hidden="true">
                                <option value="图链接">图片+链接</option>
                                <option value="产品列表">产品列表</option>
                                <option value="产品详情">产品详情</option>
                                <!--<option value="文章列表">文章列表</option>-->
                            </select>
                        </div>
                    </div>
                </div>
                <div class="box-body">
                    <div class="form-group 1">
                        <label class="col-sm-2 control-label">名称</label>
                        <div class="col-sm-6">
                            <div class="input-group">
                                <span class="input-group-addon"><i class="fa fa-pencil"></i></span>
                                <input type="test" name="name" value="" class="form-control" placeholder="名称">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="box-body img-link">
                    <div class="form-group 1">
                        <label class="col-sm-2 control-label">链接</label>
                        <div class="col-sm-6">
                            <div class="input-group">
                                <span class="input-group-addon"><i class="fa fa-pencil"></i></span>
                                <input type="test" name="url" value="" class="form-control" placeholder="链接">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="box-body">
                    <div class="form-group 1">
                        <label class="col-sm-2 control-label">图片</label>
                        <div class="col-sm-6">
                            <input type="file" id="image" data-max-file-count="1" />
                            <input type="hidden" id="image_action"/>
                        </div>
                    </div>
                </div>
                <div for="image" class="form-group 1">
                    <label class="col-sm-2 control-label"></label>
                    <div class="col-sm-6" style="margin-left: 16px; color: #da2424">* 建议宽高750px*500px</div>
                </div>
                <div class="box-body">
                    <div class="form-group 1">
                        <label class="col-sm-2 control-label">排序</label>
                        <div class="col-sm-6">
                            <div class="input-group">
                                <span class="input-group-addon"><i class="fa fa-pencil"></i></span>
                                <input type="test" name="order" value="" class="form-control" placeholder="排序">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="box-body">
                    <div class="form-group 1">
                        <label class="col-sm-2 control-label">显示</label>
                        <div class="col-sm-6">
                            <div class="input-group">
                                否 <input type="radio"  name="status" value="0" >
                                是 <input type="radio" name="status" value="1" checked="">
                            </div>
                        </div>
                    </div>
                </div>
                <!-- /.box-body -->
                <div class="box-footer">
                    <div class="col-sm-2">

                    </div>
                    <div class="col-sm-6">

                        <div class="btn-group pull-left">
                            <button type="submit" class="btn btn-info pull-right">提交</button>
                        </div>
                    </div>

                </div>
                <!-- /.box-footer -->
            </form>
        </div>

    </div></div>

    </section>
</div>
<!-- 底部 -->
<include file="Public/common_footer" />
<!--上传插件-->
<link rel="stylesheet" href="/Public/admin/fileinput/fileinput.min.css">
<script src="/Public/admin/fileinput/fileinput.min.js"></script>
<script>
    // 上传图片js
    $("#image").fileinput({
        overwriteInitial: true,
        dropZoneEnabled: false,
        uploadUrl: '/admin/upload/index/"',
        language: 'zh',
        showRemove: false,
        maxFileCount: 1,
        browseClass: 'btn btn-primary btn-docup',
        showPreview: true,
        uploadClass: 'btn btn-default btn-docup',
        allowedFileTypes: ["image"],
        browseLabel: "添加图片",
        uploadLabel: "上传图片",
        /*            initialCaption:"{$cat['cat_img']}",
         <if condition= "(!empty($cat['cat_img']))">
         initialPreview:['<img src="/Uploads/{$cat[cat_img]}" class="file-preview-image">' + '<div class="file-thumbnail-footer"><div class="file-footer-caption" title="{$cat[cat_img]}">{$cat[cat_img]}</div><div class="file-thumb-progress"><div class="progress"><div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width:100%;">100%</div></div></div> <div class="file-actions"><div class="file-footer-buttons"><button type="button" class="kv-file-upload btn btn-xs btn-default" title="Upload file" style="display: none;">   <i class="glyphicon glyphicon-upload text-info"></i></button><button type="button" class="kv-file-remove btn btn-xs btn-default" title="Remove file"><i class="glyphicon glyphicon-trash text-danger"  images="cat_img"></i></button></div><div class="file-upload-indicator" title="Uploaded"><i class="glyphicon glyphicon-ok-sign text-success"></i></div></div></div>']
         </if>*/
    }).on("fileuploaded", function (event, data, previewId, index) {
        var response = data.response;
        if (data.jqXHR.status == 200) {
            // ajax 成功返回数据写入
            $('.file-preview-frame').eq(index).append("<input class='abc' type='hidden' name='img' value='"+response+"'>");
        }
    });
    $("#image").on('filecleared', function(event) {
        $("#image_action").val(1);
    });

    $('.submit').submit();
    $('#Continent').change(function () {
        //获取下拉框选中项的index属性值
        var selectIndex = $('#Continent').get(0).selectedIndex;
        if (selectIndex !=0) {
            $('.img-link').css('display','none');
        }else {
            $('.img-link').css('display','block');
        }
    });
</script>